package com.guoguo.service.impl;

import com.guoguo.entity.Buys;
import com.guoguo.mapper.BuyMapper;
import com.guoguo.mapper.UsersMapper;
import com.guoguo.service.BuysService;
import com.guoguo.utils.UUIDUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

/**
 * Created by Administrator on 2017/9/29 0029.
 */

     /*
                           _ooOoo_
                          o8888888o
                          88" . "88
                          (| -_- |)
                          O\  =  /O
                       ____/`---'\____
                     .'  \\|     |//  `.
                    /  \\|||  :  |||//  \
                   /  _||||| -:- |||||-  \
                   |   | \\\  -  /// |   |
                   | \_|  ''\---/''  |   |
                   \  .-\__  `-`  ___/-. /
                 ___`. .'  /--.--\  `. . __
              ."" '<  `.___\_<|>_/___.'  >'"".
             | | :  `- \`.;`\ _ /`;.`/ - ` : | |
             \  \ `-.   \_ __\ /__ _/   .-` /  /
        ======`-.____`-.___\_____/___.-`____.-'======
                           `=---='
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                 佛祖保佑       永无BUG
        */
@Service
public class BuysServiceImpl implements BuysService {
    @Autowired
    private BuyMapper buyMapper;

    @Override
    public List<Buys> getUserBuys(Buys buys) {
        return buyMapper.getUserBuys(buys);
    }

    @Override
    public Buys saveBus(String userId, String orderId, String albId) {
        Buys buys = new Buys();
        buys.setBuyId(UUIDUtils.getUUID());
        buys.setUserId(userId);
        buys.setOrderId(orderId);
        buys.setAlbId(albId);
        buys.setBuyTime(new Date());
        int num = buyMapper.saveBuys(buys);

        return buyMapper.findBuysById(buys.getBuyId());
    }
}
